Class SimplyPresentable::Presenter
In: vendor/plugins/simply_presentable/lib/simply_presentable/presenter.rb
Parent: Object

Methods

Attributes

renderer  [W] 

Public Class methods

not_used_for specifies the classes that this presenter will NOT have its methods exposed on when Renderer.present is called. It is useful when there is a presenter that should be used for a class, but not one or more of its subclasses:

  class Foo; end; class Bar < Foo; end
  used_for :foo
  not_used_for :bar

[Source]

     # File vendor/plugins/simply_presentable/lib/simply_presentable/presenter.rb, line 114
114:       def not_used_for(*underscored_class_names)
115:         underscored_class_names.each do |ucn|
116:           PresenterCollection.add_exemption(ucn, self.name.underscore)
117:         end
118:       end

used_for specifies the classes that this presenter will have its methods exposed on when Renderer.present is called. If a class is specified that has alredy been specified by a parent of this presenter, this presenters methods will be exposed instead of the methods of the superclass of this presenter. If another presenter will be used for the same class and has an identically named public presenter method, the presenter that will actually be used is indeterminate.

The class names passed as arguments should be underscored and have constant de-reference operators replaced with forward slashes:

  • Foo => :foo
  • Foo::Bar => :"foo/bar"

[Source]

     # File vendor/plugins/simply_presentable/lib/simply_presentable/presenter.rb, line 101
101:       def used_for(*underscored_class_names)
102:         underscored_class_names.each do |ucn|
103:           PresenterCollection.add_presenter(ucn, self.name.underscore)
104:         end
105:       end

Public Instance methods

[Source]

     # File vendor/plugins/simply_presentable/lib/simply_presentable/presenter.rb, line 128
128:     def cache_renderer
129:       @cached_renderers ||= []
130:       @cached_renderers << @renderer
131:     end

[Source]

     # File vendor/plugins/simply_presentable/lib/simply_presentable/presenter.rb, line 133
133:     def restore_renderer
134:       @renderer = @cached_renderers.pop unless @cached_renderers.empty?
135:     end

[Validate]